-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CheckboxControl: move icons out of labels #45535
CheckboxControl: move icons out of labels #45535
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @brookewp! I like how clean things look now.
A minor thing: It feels that spacing is a bit off on this branch compared to the trunk.
trunk | this branch |
---|---|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the nice cleanup!
+1 on the vertical alignment thing from @Mamaduka, though the screenshots seem flipped 😆
margin-right: $grid-unit-15; | ||
fill: $gray-900; | ||
} | ||
svg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be careful with element selectors like svg
, as in this case where it's unintentionally applying to the checkmark svg as well 😄
The normal suggested way would be to add our own className to Icon
for better scoping.
It might also be nice to add a flex-grow: 0
in here so the icon doesn't shrink when the checkbox text is long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be careful with element selectors like svg, as in this case where it's unintentionally applying to the checkmark svg as well 😄
Good catch! I usually have a good eye for that, so I'm surprised I missed that! 🤦♀️
It might also be nice to add a
flex-grow: 0
in here so the icon doesn't shrink when the checkbox text is long.
I might be missing something, but I'm having trouble getting flex-grow: 0
to work in that scenario. Would it be a bad idea to set a min-width
on the icon instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I meant flex-shrink 🙈 Does that work?
} | ||
svg { | ||
margin-right: $grid-unit-15; | ||
fill: $gray-900; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fill
hack is not ideal (#40102), but I understand why it's needed at the moment. (No action required, just mentioning for future context.)
@@ -25,24 +25,14 @@ | |||
} | |||
} | |||
.block-editor-block-lock-modal__checklist-item { | |||
display: flex; | |||
justify-content: space-between; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth adding a flex-gap
so the text and icon don't run together when the text is long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me!
8c4891e
to
9285615
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @brookewp!
I've center-aligned it now but I think it is a pixel off. Will that be an issue? What do you think?
That's okay with me. The items are correctly aligned.
9285615
to
bfef1c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you! 🚀
What?
The icons for
BlockLockModal
andBlockTypesChecklist
were nested inside theCheckboxControl
label. This PR moves them out of the label and removes unnecessary CSS.Why?
This PR is based on the comment here: #45434 (comment) by @mirka
How?
Moving the
Icon
andBlockIcon
components out of thelabel
prop. Also, removing the CSS forcomponents-base-control__field
andcomponents-checkbox-control__label
and moving it to the parent class for the respective components.Testing Instructions
For
BlockLockModal
Restrict editing
that some other blocks don't have, i.e the Paragraph block)-- Make sure the icon shows the correct lock based on if it's locked or unlocked
-- Ensure background hover works as expected
-- Changes are responsive
For
BlockTypesChecklist
-- Ensure it looks the same as before (it's about a pixel different in vertical spacing, not sure if that'll be an issue)
-- Check that it's responsive